<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('选择会员赠送优惠券')"/>
</head>

<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="shop-product-add-form">
                <input type="hidden" name="isEnable" value="1">
                <input type="hidden" name="couponIdStr" id="couponIdStr" th:value="${couponIdStr}">
                <div class="select-list">
                    <ul>
                        <li>
                            <p style="width: 90px;">手机号：</p>
                            <input type="text" name="phone"/>
                        </li>
                        <li class="select-time">
                            <p style="width: 90px;">注册时间：</p>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "back/shopCoupon";

    $(function () {
        var options = {
            url: ctx + "back/shopMember/list",
            modalName: "受赠会员",
            columns: [
                {
                    checkbox:true
                },
                {
                    field:'id',
                    title:"ID",
                    sortable: true
                },
                {
                    field: 'vipTypeName',
                    title: "会员等级",
                    sortable: true
                },
                {
                    field: 'nickname',
                    title: '昵称'
                },
                {
                    field: 'avatar',
                    title: '头像',
                    formatter: function (value, row, index) {
                        return $.common.sprintf("<img class='img-circle img-sm' data-height='%s' data-width='%s' data-target='%s'  style='border-radius: 0;' src='%s'/>", 500, 'auto', 'self', value);
                    }
                },
                {
                    field: 'phone',
                    title: '手机号',
                },
                {
                    field: 'credit',
                    title: '积分',
                    sortable: true,
                },
                {
                    field: 'balance',
                    title: '余额',
                    sortable: true,
                },
                {
                    field: 'totalRechargeAmount',
                    title: '累计充值',
                    sortable: true,
                },
                {
                    field: 'totalPetrolAmount',
                    title: '累计加油（微信支付）',
                    sortable: true,
                },
                {
                    field: 'createTime',
                    title: '注册时间',
                    sortable: true
                }]
        };
        $.table.init(options);
    });

    function queryParams(params) {
        var search = $.table.queryParams(params);
        search.couponIdStr = $('#couponIdStr').val();
        return search;
    }

    /* 新增售卖商品-选择商品-提交 */
    function submitHandler() {
        var rows = $.table.selectFirstColumns();
        if (rows.length == 0) {sendToMember
            $.modal.alertWarning("请至少选择一名受赠会员");
            return;
        }
        var data = {"memberIdStr": rows.join(),"couponIdStr":$('#couponIdStr').val()};
        $.operate.save(prefix + "/sendToMember", data);
    }
</script>
</body>
</html>